import store from '@/store'
import Vue from 'vue'

export function hasPermission(permission) {
  const myPermissions = store.getters.permissionList
  return myPermissions.indexOf(permission) > -1
}
export function buttonList(permission) {
  const myPermissions = store.getters.permissionList
  return myPermissions.indexOf(permission) > -1
}
export function bomCoster(permission) {
  const myPermissions = store.getters.permissionList
  return myPermissions.indexOf(permission) > -1
}
export function orderPurchase(permission) {
  const myPermissions = store.getters.permissionList
  return myPermissions.indexOf(permission) > -1
}
export function statement(permission) {
  const myPermissions = store.getters.permissionList
  return myPermissions.indexOf(permission) > -1
}

Vue.prototype.button = buttonList
Vue.prototype.hasPerm = hasPermission
Vue.prototype.bomCost = bomCoster
Vue.prototype.orderPurchase = orderPurchase
Vue.prototype.statement = statement
Vue.prototype.$img = '' // 图片加前缀
Vue.prototype.flanguage = localStorage.getItem('lang') || 'zh'
/* 摩洛哥项目8868， 惠州杰希8878  */
// 杰希、摩洛哥、内销
const publicPath = location.pathname
if (publicPath.indexOf('jc-web') !== -1) { // 惠州杰希 8878
  Vue.prototype.allots = true
  Vue.prototype.allotnx = false
  Vue.prototype.$img = '/jc'
  Vue.prototype.$url = 'http://14.29.79.10:8878'
  Vue.prototype.$conUrl = 'http://14.29.79.10:8808/jc'
} else if (publicPath.indexOf('mlg-web') !== -1) { // 摩洛哥 8868
  Vue.prototype.allots = false
  Vue.prototype.allotnx = false
  Vue.prototype.$img = '/mlg'
  Vue.prototype.$url = 'http://14.29.79.10:8868'
  Vue.prototype.$conUrl = 'http://14.29.79.10:8808' // 不要改
} else if (publicPath.indexOf('nx-web') !== -1) { // 惠州杰希内销 8858
  Vue.prototype.allots = false
  Vue.prototype.allotnx = true
  Vue.prototype.$img = '/nx'
  Vue.prototype.$url = 'http://14.29.79.10:8858'
  Vue.prototype.$conUrl = 'http://14.29.79.10:8808/nx'
} else { // 线下
  Vue.prototype.allots = true
  Vue.prototype.allotnx = false
  Vue.prototype.$url = 'http://14.29.79.10:8878'
  Vue.prototype.$conUrl = 'http://14.29.79.10:8808/jc'
}
